#pragma once
#include <vector>
#include <cstdint>
#include <functional>
#include <deque>
#include <string>

namespace eintik::data::scan {
    struct PosFrame 
    {
        std::vector<uint8_t> c;
        int32_t t;
    };

    struct FileInfo
    {
        double pos_start = 0.0;
        double pos_end = 0.0;
        std::string file_name;
    };

    struct FileCache
    {
        FileCache();
        ~FileCache();

        void register_scan(uint64_t scan);
        void unregister_scan(uint64_t scan);
        bool save_data(uint64_t scan, const std::deque<PosFrame> &dq, double pos_start, double pos_end);
        bool load_data(uint64_t scan, double pos, std::deque<PosFrame> &dq, int cnt_point);

    private:
        std::unordered_map<uint64_t, std::vector<FileInfo>> files;
    };

    FileCache *file_cache();
}